﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <div>
    <el-form ref="formRefAndonStationHeader" :model="stateAndonStationHeader.vmModel" label-width="100px">
      <el-row>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_StationId_FormItem" prop="Entity.StationId" :label="$t('message.autotrans._Model_AndonStationHeader_Station')">
            <el-select v-model="stateAndonStationHeader.vmModel.Entity.StationId" disabled clearable>
               <el-option v-for="item in stateAndonStationHeader.AllStations" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_HeaderRole_FormItem" prop="Entity.HeaderRole" :label="$t('message.autotrans._Model_AndonStationHeader_HeaderRole')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_AndonStationHeader_HeaderRole')}), trigger: 'blur' }]" >
            <el-input v-model="stateAndonStationHeader.vmModel.Entity.HeaderRole" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Header_FormItem" prop="Entity.Header" :label="$t('message.autotrans._Model_AndonStationHeader_Header')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_AndonStationHeader_Header')}), trigger: 'blur' }]" >
            <el-input v-model="stateAndonStationHeader.vmModel.Entity.Header" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ContactNumber_FormItem" prop="Entity.ContactNumber" :label="$t('message.autotrans._Model_AndonStationHeader_ContactNumber')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_AndonStationHeader_ContactNumber')}), trigger: 'blur' }]" >
            <el-input v-model="stateAndonStationHeader.vmModel.Entity.ContactNumber" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_CreateTime_FormItem" prop="Entity.CreateTime" :label="$t('message.autotrans._Model_AndonStationHeader_CreateTime')">
            <el-input v-model="stateAndonStationHeader.vmModel.Entity.CreateTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_UpdateTime_FormItem" prop="Entity.UpdateTime" :label="$t('message.autotrans._Model_AndonStationHeader_UpdateTime')">
            <el-input v-model="stateAndonStationHeader.vmModel.Entity.UpdateTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_CreateBy_FormItem" prop="Entity.CreateBy" :label="$t('message.autotrans._Model_AndonStationHeader_CreateBy')">
            <el-input v-model="stateAndonStationHeader.vmModel.Entity.CreateBy" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_UpdateBy_FormItem" prop="Entity.UpdateBy" :label="$t('message.autotrans._Model_AndonStationHeader_UpdateBy')">
            <el-input v-model="stateAndonStationHeader.vmModel.Entity.UpdateBy" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_IsValid_FormItem" prop="Entity.IsValid" :label="$t('message.autotrans._Model_AndonStationHeader_IsValid')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_AndonStationHeader_IsValid')}), trigger: 'blur' }]" >
            <el-input v-model="stateAndonStationHeader.vmModel.Entity.IsValid" disabled clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

      <div style="text-align:right;">
        <WtmButton @click="onCloseAndonStationHeader"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

      </div>

    </el-form>

  </div>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageAndonManagementAndonStationHeaderDetails;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { andonstationheaderApi } from '/@/api/andonmanagement/andonstationheader';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefAndonStationHeader = ref();
const stateAndonStationHeader = reactive({
    vmModel: {
	  Entity:{
        StationId: null,
        HeaderRole: '',
        Header: '',
        ContactNumber: '',
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
        IsValid: undefined,
        ID:null,
      },

	},
    
    AllStations: [] as any[],
});

// 取消
const onCloseAndonStationHeader = () => {
    closeDialog();
};

// 提交
const onSubmitAndonStationHeader = () => {
 	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});
   formRefAndonStationHeader.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            andonstationheaderApi().edit(stateAndonStationHeader.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
        else{
			loadingInstance.close();
        }
	})
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/AndonManagement/AndonStationHeader/GetAndonStations',[],false).then(x=>{stateAndonStationHeader.AllStations = x});
    if (ci.attrs["wtmdata"]) {
		stateAndonStationHeader.vmModel.Entity.ID = ci.attrs["wtmdata"].ID;
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateAndonStationHeader.vmModel.Entity.ID = useRouter().currentRoute.value.query.id as any;
	}
	andonstationheaderApi().get(stateAndonStationHeader.vmModel.Entity.ID ?? "").then((data: any) => other.setValue(stateAndonStationHeader.vmModel, data));
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

